home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gxsample.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  2.8 KB  |  76 lines

  1. /* Copyright (C) 1997, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gxsample.h,v 1.2 2000/09/19 19:00:40 lpd Exp $ */
  20. /* Sample lookup and expansion */
  21.  
  22. #ifndef gxsample_INCLUDED
  23. #  define gxsample_INCLUDED
  24.  
  25. /*
  26.  * The following union implements the expansion of sample
  27.  * values from N bits to 8, and a possible linear transformation.
  28.  */
  29. typedef union sample_lookup_s {
  30.     bits32 lookup4x1to32[16];    /* 1 bit/sample, not spreading */
  31.     bits16 lookup2x2to16[16];    /* 2 bits/sample, not spreading */
  32.     byte lookup8[256];        /* 1 bit/sample, spreading [2] */
  33.     /* 2 bits/sample, spreading [4] */
  34.     /* 4 bits/sample [16] */
  35.     /* 8 bits/sample [256] */
  36. } sample_lookup_t;
  37.  
  38. /*
  39.  * Define identity and inverted expansion lookups for 1-bit input values.
  40.  * These can be cast to a const sample_lookup_t.
  41.  */
  42. extern const bits32 lookup4x1to32_identity[16];
  43. extern const bits32 lookup4x1to32_inverted[16];
  44.  
  45. /*
  46.  * Define procedures to unpack and shuffle image data samples.  The Unix C
  47.  * compiler can't handle typedefs for procedure (as opposed to
  48.  * pointer-to-procedure) types, so we have to do it with macros instead.
  49.  *
  50.  * The original data start at sample data_x relative to data.
  51.  * bptr points to the buffer normally used to deliver the unpacked data.
  52.  * The unpacked data are at sample *pdata_x relative to the return value.
  53.  *
  54.  * Note that this procedure may return either a pointer to the buffer, or
  55.  * a pointer to the original data.
  56.  */
  57. #define SAMPLE_UNPACK_PROC(proc)\
  58.   const byte *proc(P7(byte *bptr, int *pdata_x, const byte *data, int data_x,\
  59.               uint dsize, const sample_lookup_t *ptab, int spread))
  60. typedef SAMPLE_UNPACK_PROC((*sample_unpack_proc_t));
  61.  
  62. /*
  63.  * Declare the 1-for-1 unpacking procedure.
  64.  */
  65. SAMPLE_UNPACK_PROC(sample_unpack_copy);
  66. /*
  67.  * Declare unpacking procedures for 1, 2, 4, and 8 bits per pixel,
  68.  * with optional spreading of the result.
  69.  */
  70. SAMPLE_UNPACK_PROC(sample_unpack_1);
  71. SAMPLE_UNPACK_PROC(sample_unpack_2);
  72. SAMPLE_UNPACK_PROC(sample_unpack_4);
  73. SAMPLE_UNPACK_PROC(sample_unpack_8);
  74.  
  75. #endif /* gxsample_INCLUDED */
  76.